 const store = {
    state: {
        num: 20
    },
    //只放同步的方法
    actions: {
        add1(newState : {num : number},action : {type: string}) {
            newState.num++
        },
        add2(newState : {num : number},action : {type: string, val: number}) {
            newState.num += action.val
        },
        add3(newState : {num : number},action : {type: string, val: number}) {
            newState.num += action.val
        }
    },
    //放异步方法  优化redux-thunk的写法
    asyncActions:{
        asyncAdd1(dispatch:Function){
            setTimeout(() => {
                dispatch({type: 'add1'})
            },1000)
        }
    },
    //actions方法名字的统一管理
    actionNames:{}
}

let actionNames = {}
for(let key in store.actions){
    actionNames[key] = key
}
store.actionNames = actionNames

export default store